<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class DataSource extends Bones {
	protected $ID;
	
	protected $addGlobalId;
	protected $clientOnly;
	
	protected $autoCacheAllData;
	protected $cacheAllData;
	protected $cacheData;
	protected $cacheMaxAge;
	protected $criteriaPolicy;
	protected $preventHTTPCaching;
	
	protected $autoConvertRelativeDates;
	protected $autoDeriveTitle;
	
	protected $callbackParam;
	
	protected $canMultiSort;
	
	protected $childrenField;
	protected $descriptionField;
	
	protected $dataField;
	protected $dataFormat;
	protected $dataProtocol;
	protected $dataTransport;
	protected $dataURL;
	
	protected $fields;
	protected $iconField;
	protected $infoField;
	protected $titleField;
	
	protected $inheritsFrom;
	protected $showLocalFieldsOnly;
	protected $useParentFieldOrder;
	
	protected $jsonPrefix;
	protected $jsonSuffix;
	
	protected $noNullUpdates;
	protected $omitNullDefaultsOnAdd;
	protected $nullBooleanValue;
	protected $nullDateValue;
	protected $nullFloatValue;
	protected $nullIntegerValue;
	protected $nullStringValue;
	
	protected $operationBindings;
	
	protected $pluralTitle;
	
	protected $requiredMessage;
	
	protected $showPrompt;
	
	protected $sparseUpdates;
	
	
	/**
	 * Constructeur
	 */
	public function DataSource($id, $format = Constant::DATA_FORMAT_JSON) {
		parent::Bones();
		
		$this->ID = $id;
		$this->cacheData = array();
		$this->fields = array();
		$this->operationBindings = array();
		$this->dataURL = "index.php";
		$this->dataFormat = $format;
		$this->dataProtocol = Constant::DATA_PROTOCOL_POST;
	}
	
	/**
	 * permet d'ajouter un champ
	 * @param DataSourceField $field
	 */
	public function addField(DataSourceField $field) {
		$this->fields[] = $field;
	}
	
	/**
	 * Renvoie l'ID du dataSource
	 */
	public function getID() {
		return $this->ID;
	}
}

/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class OperationBinding extends Bones implements IRenderable {
	
	protected $allowMultiUpdate;
	protected $autoJoinTransactions;
	protected $cacheSyncOpeartion;
	protected $callbackParam;
	protected $canSyncCache;
	protected $invalidateCache;
	protected $spoofResponses;
	
	protected $useFlatFields;
	
	protected $wsOperation;
	
	protected $dataFormat;
	protected $dataProtocol;
	protected $dataTransport;
	protected $dataURL;
	protected $defaultParams;
	protected $requestProperties;
	
	protected $groupClause;
	
	protected $lineBreakStyle;
	
	protected $operationId;
	protected $operationType;
	
	protected $values;
	
	/**
	 * Constructeur
	 */
	public function OperationBinding() {
		parent::Bones();
		
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return get_class($this);
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}
	
	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		ScCollectionLog::getInstance()->addSc(new ScLog($this->object(), get_object_vars($this)));
	}

	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "{".$this->properties()."}";
	}
}

/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class DataSourceField extends Bones implements IRenderable {
	protected $name;
	protected $title;
		
	protected $canEdit;
	protected $canFilter;
	protected $canSave;
	protected $canSortClientOnly;
	protected $detail;
	protected $multiple;
	
	protected $displayFormat;
	protected $editorType;
	protected $type;
	
	protected $primaryKey;
	protected $foreignKey;
	protected $group;
	protected $rootValue;
	
	protected $hidden;
	protected $ignore;
	protected $required;
	
	protected $imageHeight;
	protected $imageWidth;
	protected $imageSize;
	protected $maxFileSize;
	protected $showFileInline;
	protected $uploadFieldName;
	
	protected $valueMap;
	
	/**
	 * Constructeur
	 * @param unknown_type $name
	 * @param unknown_type $type
	 * @param unknown_type $primaryKey
	 * @param unknown_type $title
	 */
	public function DataSourceField($name, $type, $title = null, $primaryKey = null, $canEdit = null, $hidden = null) {
		parent::Bones();
		
		$this->name = $name;
		$this->type = $type;
		$this->primaryKey = $primaryKey;
		$this->title = $title;
		$this->canEdit = $canEdit;
		$this->hidden = $hidden;
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return null;
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}
	
	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		//
	}

	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "{".$this->properties()."}";
	}
	
}